package com.yj.util;

import com.yj.web.MappingValue;
import org.dom4j.Element;

import java.util.HashMap;
import java.util.Map;

public class XmlConfigReader {


    public Map<String, MappingValue> loadConfig(Resource resource){
        Map<String, MappingValue> mappingValues = new HashMap<>();
        while (resource.hasNext()){
            Element element = (Element) resource.next();
            String uri = element.attributeValue("id");
            String className = element.attributeValue("class");
            String methodName = element.attributeValue("value");
            MappingValue mappingValue = new MappingValue(uri, className, methodName);
            mappingValues.put(uri, mappingValue);
        }
        return mappingValues;
    }


}
